package cl.ccs.migracionbcmc.dao.impl;

import cl.ccs.migracionbcmc.connection.ConnectionFactory;
import cl.ccs.migracionbcmc.dao.VerifCarteraDao;

import cl.ccs.migracionbcmc.model.RangoBoletinesVig;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Types;

public class VerifCarteraDaoImpl implements VerifCarteraDao {

    public VerifCarteraDaoImpl() {
            super();
        }

    /**
     * @return
     */
    @Override
        public RangoBoletinesVig obtieneBoletinesVig() {
            Connection con = null;

            RangoBoletinesVig rangobolvig = new RangoBoletinesVig();
             try{
                 con = ConnectionFactory.getConnectionSybaseBIC();
                 
                 CallableStatement stm = con.prepareCall("{?=CALL SQ_BolDesdeHasta_VerCar(?,?)}");
                 stm.registerOutParameter(1, Types.INTEGER);
                 
                 stm.registerOutParameter(2, Types.SMALLINT); //Boletin Desde
                 stm.registerOutParameter(3, Types.SMALLINT); //Boletin Hasta
                 
                 stm.execute();
                 
                 rangobolvig.setBoletinDesde(stm.getInt(2));
                 rangobolvig.setBoletinHasta(stm.getInt(3));
                   
                
                 
             }catch(Exception e){
                 e.printStackTrace();
             }finally{
                 ConnectionFactory.freeConnection(con);
             }
             
            return rangobolvig;
        }

}
